<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="mengxiangzhong">
<title>测试页面</title>
<script language="javascript" src="/script/common.js"
	type="text/javascript"></script>
<script language="javascript" src="/script/card.js"
	type="text/javascript"></script>
<script language="javascript" src="zhbus.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">

DWR._errorHandler = function(message,async) {
	var msg = message;
	if (typeof message == "object" && message.name == "Error" && message.description) {
		msg = message.description;
	}
	if (msg == "session time out"){
		loginOper()
	}else{
		if(!async){
			throw new Error(msg + "");
		}
		else{
			showError(msg);
		}
	}
}
function loginOper(){
	var loginName = window.prompt("loginName:","")
	var password = window.prompt("password:","")
	try{
		DWR.syncCall("loginService.login",loginName,password)
		showInformation("操作员登录成功")
	}catch(e){showError(e.description)}
}
	var cOrg;
	var cOper;
		//初始化页面信息
	function load(){
		cOrg = DWR.syncCall("loginService.currentOrg")
		cOper = DWR.syncCall("loginService.currentOperator")
		if (!cOrg || !cOper){
			showWarning("操作员未登录，请登录！");
			loginOper()
			cOrg = DWR.syncCall("loginService.currentOrg")
			cOper = DWR.syncCall("loginService.currentOperator")
		}
		$("operatorUniqueId").value = cOper.uniqueId
		setOrg(cOrg);
		DWR.call("zhgjService.findGifts",function(res){
			Common.initDict($("giftSelect"),res,"小额支付","0","1")
		})
		Common.initDict($("currency"),"currency")
 	}
 	//选择卡类型
 	var cardTypeId;
 	function selCardType(){	
		var v = openDialogFrame("/basic/card_type_list.html?",'请选择卡片类型',464,700)
		if (v){
			cardTypeId=v[0];
			$("cardType").value = v[1];
		}
 	}
 	//卡入库
 	function cardin(){
 		var asn = $("petroasn").value
 		var storeLocationId = $("storeLocationId").value
 		DWR.call("expandCardMgntService.testAddCard",asn,cardTypeId,{id:storeLocationId},function(){
 			alert("ok")
 		})
 	}
 	//读卡
 	function readCard(){
 		try{
	 		getCard();
	 		$("petroasn").value = getAsn();
 		}catch(e){
 			showError(e.description)
 		}
 	}
 	
 	function readPsamCard(){
 		try{
			var psamData = getPsamTN();
		 	$("petroasn").value = psamData.PsamSN;
 		}catch(e){
 			showError(e.description)
 		}
 	}
 	function selOrg(){
 		SystemMgnt.selOrg(setOrg,{orgId:cOrg.id})
 	}
 	function setOrg(org){
 		$("storeLocationId").value = org.id;
 		$("storeLocationName").value = org.name;
 	}
 	function test1(){
 		DWR.call("pospService.testfunc",function(r){alert(r)})
 	}
	</script>
	<style>
	TABLE{
		width:600px;
		border:1px solid #000000;
		margin-top:10px;
	}
	TABLE TH{
		height:18px;
		background:#afafaf;
		color:#000000;
	}
	#petro select{width:120px;}
	</style>
</head>
<body onload="load()" onunload="releaseCard()">
<!--页面导航-->
<div class="nav">
<div id="nav"></div><div style="float:right;"><button onclick="test1()">test</button><button onclick="loginOper()">login</button></div>
</div>
<div id="petro">
<table border=1 class="label4 col3">
	<tr>
		<th colspan=3>卡号</th>
	</tr>
	<tr>
		<td><label>卡号</label></td>
		<td><input type="text" id="petroasn"></td>
		<td>
		<button onclick="readCard()">读卡</button>
		<button onclick="readPsamCard()">读PSAM卡</button>
		</td>
	</tr>
</table>
<table border=1 class="label4 col3">
	<tr>
		<th colspan=3>卡片入库</th>
	</tr>
	<tr>
		<td><label>所属机构</label></td>
		<td><input type="text" id="storeLocationName" readonly class="readonly"
			onblur="checkV(this,'',true)"> <a class="orga"
			title="请选择机构" href="javascript:void(0)" onclick="selOrg()">&nbsp;&nbsp;</a>
		</td>
		<td>
			<input type="hidden" id="storeLocationId">
		</td>
	</tr>
	<tr>
		<td><label>卡类型</label></td>
		<td><input type="text" id="cardType" readonly class="readonly"
			onblur="checkV(this,'',true)"> <a class="orga"
			title="请选择卡片类型" href="javascript:void(0)" onclick="selCardType()">&nbsp;&nbsp;</a>
		</td>
		<td>
		<button onclick="cardin()">入库</button>
		</td>
	</tr>
</table>
<table border=1 class="label6 col3">
	<tr>
		<th colspan=3>模拟POS操作</th>
	</tr>
	<tr>
		<td><label>支付币种</label></td>
		<td><select id="currency"></select></td>
		<td>
			&nbsp;
		</td>
	</tr>
	<tr>
		<td><label>终端编号</label></td>
		<td><input type=text id=posUniqueId value="12345678">
		<img src="/images/table/drop-no.gif" id="pos_login_img">
		</td>
		<td>
			<button onclick="posLogin()">终端开机</button>
		</td>
	</tr>
	<tr>
		<td><label>操作员编号</label></td>
		<td><input type=text id=operatorUniqueId value="">
		<td>&nbsp;
		</td>
	</tr>
	<tr>
		<td><label>操作员密码</label></td>
		<td><input type=text id=operpassword value="111111">
		<img src="/images/table/drop-no.gif" id="sign_in_img"></td>
		<td>
			<button onclick="signIn()">签到</button>
			<button onclick="signOut()">签退</button>
		</td>
	</tr>
	<tr>
		<td><label>操作员密码</label></td>
		<td><input type=text id=posUnLockPassword></td>
		<td><button onclick="posUnLock()">终端解锁</button></td>
	</tr>
	<tr>
		<td><label>操作员改密</label></td>
		<td>
			<input type=text id=oldpassword><br>
			<input type=text id=newpassword>
		</td><td>
			<button onclick="changePassword()">修改密码</button>
		</td>
	</tr>
	<tr>
		<td><label>增加并启用汇率</label></td>
		<td><input type=text id="exchangeRate" value=150></td>
		<td><button onclick="saveExchangeRate()">启用</button><font color=gray>(1外币兑换人民币)</font></td>
	</tr>
	</table>
<table border=1 class="label6 col3">
	<tr>
		<th colspan=3>模拟卡片操作</th>
	</tr>
	<tr>
	<td><span style="color:red">卡类型</span></td><td>
		<input type="text" value="00" id="zhgjcardtype"></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
	<td><span style="color:red">有效期</span></td><td>
		<input type="text" value="2008-11-12" id="expiredTime" readonly class="readonly"><a href="javascript:void(0)" onclick="showDatePicker($('expiredTime'));" class="date" title="选择日期">&nbsp;&nbsp;</a><span class="des">*</span></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
	<td><span style="color:red">卡号</span></td><td>
		<input type="text" value="100000000000" id="asn"></td>
		<td><button onclick="sellCard()">发卡</button></td>
	</tr>
	<tr>
	<td>充值</td><td>
		<input type="text" value="100" id="amount"></td><td>
		<button onclick="cardDeposit()">充值</button>
	</td>
	</tr>
	<tr>
	<td>充值冲正</td><td>
		<input type="text" value="100" id="reversalAmount"></td><td>
		<button onclick="reversal()">充值冲正</button></td>
	</tr>
	<tr>
	<td>交易流水号</td><td>
		<input type="text" id="tradeId"></td><td>
		<button onclick="cancelTrade()">充值撤销</button></td>
	</tr>
	<tr>
	<td>年审</td><td>&nbsp;</td><td>
		<button onclick="annualAudit()">年审</button>
	</td>
	</tr>
	<tr>
		<td>退卡</td><td>&nbsp;</td>
		<td><button onclick="retCard()">退卡</button></td>
	</tr>
	<tr>
	<td>是否黑名单</td><td>&nbsp;</td><td>
		<button onclick="checkBlackCard()">检验</button>
	</td>
	</tr>
	<tr>
	<td>对帐</td><td>&nbsp;</td><td>
		<button onclick="settle()">对帐</button>
	</td>
	</tr>
	<tr>
	<td>连安控POS</td><td>&nbsp;</td><td>
		<button onclick="connectHSPos()">CONNECT</button>
	</td>
	</tr>
	<tr>
	<td>消费</td><td>
		<select id="giftSelect" style="width:70px;"></select>
		<input type="text" value="100" id="purchaseAmount" style="width:40px;"></td><td rowspan=2>
		<button onclick="cardPurchase()">消费</button>
	</td>
	</tr>
	<tr>
	<td>折扣</td><td>
		<input type="text" value="0" id=discount>元</td>
	</tr>
	<tr>
	<td>备用金余额</td><td>
		<input type="text" value="" id="spareBalance"></td><td>
		<button onclick="querySpareBalance()">查询</button>
	</td>
	</tr>
	<tr>
	<td>圈存</td><td>
		<input type="text" value="100" id="loadAmount"></td><td>
		<button onclick="cardLoad()">圈存</button>
	</td>
	</tr>
	<tr>
	<td>查看库存</td><td>
		&nbsp;</td><td>
		<button onclick="getCardReport()">查看库存</button>
	</td>
	</tr>
	
	<tr><td colspan=3 align=center>
		<button onclick="transferTx()">导充值交易</button>
		<button onclick="transferMgnt()">导MGNT交易</button>
		<button onclick="autoTransfer()">开始导入</button>
	</td>
	<tr><td colspan=3 align=center>
		<button onclick="importOldCard()">导老系统的卡</button>
	</td>
</table>

<form id="dataform" name="dataform">
<table border=1 class="label4 col3">
	<tr>
		<th colspan=3>交易数据</th>
	</tr>
	<tr>
		<td>交易类型</td>
		<td><input class="readonly" readonly name="tradeName"></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>交易流水号</td>
		<td><input class="readonly" readonly name="tradeId"></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>交易前余额</td>
		<td><input class="readonly" readonly name="balance1"></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>交易后余额</td>
		<td><input class="readonly" readonly name="balance2"></td>
		<td>&nbsp;</td>
	</tr>
</table>
</form>
</div>
</body>
</html>